package com.ht.medicaltreatment.viewmodel

import androidx.lifecycle.viewModelScope
import com.ht.medicaltreatment.bean.OrderDetail96Bean
import com.xgst.lib.http.ApiResult
import kotlinx.coroutines.launch

class NinetySixViewModel : BaseViewModel() {
    fun order96Detail(id:String, onResult:(OrderDetail96Bean?)->Unit, onError:(String)->Unit){
        viewModelScope.launch {
            val bean = mApi.order96Detail(id)
            when(bean){
                is ApiResult.Success -> onResult(bean.data.data)
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }

    fun submitCheck(checkSampleId:String,uid:String, onResult:(String?)->Unit, onError:(String)->Unit){
        viewModelScope.launch {
            val bean = mApi.submitCheck(checkSampleId,uid)
            when(bean){
                is ApiResult.Success -> onResult(bean.data.data)
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }

    fun jump(checkSampleId:String,onResult:(String?)->Unit, onError:(String)->Unit){
        viewModelScope.launch {
            val bean = mApi.jump(checkSampleId)
            when(bean){
                is ApiResult.Success -> onResult(bean.data.data)
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }
}
